package com.itheima.stargraph.controller;

import com.itheima.stargraph.dto.common.Result;
import com.itheima.stargraph.dto.request.Text2ImageReqDto;
import com.itheima.stargraph.dto.respone.Text2ImageResDto;
import com.itheima.stargraph.pojo.SgUserResult;
import com.itheima.stargraph.service.ISgUserResultService;
import com.itheima.stargraph.service.Text2ImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/authed/1.0/t2i")
public class Text2ImageController {

    @Autowired
    private ISgUserResultService iSgUserResultService;

    /**
     * 加载文生图列表
     * @return
     */
    @PostMapping("/list")
    public Result<List<SgUserResult>> list() {
        List<SgUserResult> userResultList = iSgUserResultService.resultList();
        return Result.ok(userResultList);
    }

    @Autowired
    private Text2ImageService text2ImageService;

    /**
     *添加comfyui流程任务（工作流任务）
     */
    @PostMapping("/prompt")
    public Result<Text2ImageResDto> prompt(@RequestBody Text2ImageReqDto dto){
        Text2ImageResDto imageResDto = text2ImageService.prompt(dto);
        return Result.ok(imageResDto);
    }
}